package com.beta.backend.gateway.factory;

import com.beta.backend.gateway.config.GatewayCfgBean;
import com.beta.backend.gateway.filter.ServerAuthGatewayFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Component;

/**
 * @description 用户身份认证过滤器，用于校验jwt用户信息，适用于服务端授权
 * @author: zdwang
 * @date 2021/12/2 19:10
 */
@Component
public class ServerAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<Object> {

    @Autowired
    private GatewayCfgBean gatewayCfgBean;

    @Override
    public GatewayFilter apply(Object config) {
        return new ServerAuthGatewayFilter(gatewayCfgBean);
    }
}
